
#include <stdlib.h>
#include "glut.h"

GLfloat rotate;

GLfloat ambient[] = {0.0, 0.0, 0.0, 1.0};	

GLfloat diffuse0[] = {1.0, 0.0, 0.0, 1.0};		
GLfloat specular0[] = {1.0, 0.0, 1.0, 1.0};		
GLfloat position0[] = {0.0, 10.0, 0.0, 0.0};

GLfloat diffuse2[] = {0.0, 1.0, 0.0, 1.0};		
GLfloat specular2[] = {0.0, 1.0, 1.0, 1.0};		
GLfloat position2[] = {10.0, 0.0, 0.0, 1.0};
GLfloat direction2[] = {1, 0 ,0};
GLfloat exponent2[] = {120};
GLfloat cutoff2[] = {180};

GLfloat diffuse3[] = {0.0, 0.0, 1.0, 1.0};		
GLfloat specular3[] = {1.0, 0.0, 1.0, 1.0};		
GLfloat position3[] = {0.0, -10.0, 0.0, 1.0};

void initDeissMichael(void)
{
	glClearColor(0.0, 0.0, 0.0, 0.0);
	glShadeModel(GL_FLAT);

	//========================== Beleuchtungen ein/aus-schalten=============================
	glEnable(GL_NORMALIZE);
	glEnable(GL_LIGHTING);
	glEnable(GL_LIGHT0);
	glEnable(GL_LIGHT1);
	glEnable(GL_LIGHT2);

	//================================ Lichtquelle Nr.0 ====================================
	//Punktlichtquelle gerichtet

	glLightfv(GL_LIGHT0, GL_AMBIENT, ambient);
	glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse0);
	glLightfv(GL_LIGHT0, GL_SPECULAR, specular0);
	glLightfv(GL_LIGHT0, GL_POSITION, position0);

	//================================ Lichtquelle Nr.1 ====================================
	//Spotlichtquelle

	glLightfv(GL_LIGHT1, GL_AMBIENT, ambient);
	glLightfv(GL_LIGHT1, GL_DIFFUSE, diffuse2);
	glLightfv(GL_LIGHT1, GL_SPECULAR, specular2);
	glLightfv(GL_LIGHT1, GL_POSITION, position2);
    glLightfv(GL_LIGHT1, GL_SPOT_DIRECTION, direction2);
	glLightfv(GL_LIGHT1, GL_SPOT_EXPONENT, exponent2);
	glLightfv(GL_LIGHT1, GL_SPOT_CUTOFF, cutoff2);

	//================================ Lichtquelle Nr.2 ====================================
	//Punktlichtquelle ungerichtet

	glLightfv(GL_LIGHT2, GL_AMBIENT, ambient);
	glLightfv(GL_LIGHT2, GL_DIFFUSE, diffuse3);
	glLightfv(GL_LIGHT2, GL_SPECULAR, specular3);
	glLightfv(GL_LIGHT2, GL_POSITION, position3);
}

void DeissMichaelDisplay(void)
{
	initDeissMichael();
	
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
	glEnable(GL_DEPTH_TEST);

	glLoadIdentity();
	gluLookAt(0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
	glRotatef(rotate, 0.0, 1.0, 0.0);
	glPushMatrix();



	//============================= Grundkoerper ====================================

	glColor3f (1.0, 1.0, 1.0); //Farbe Weiss
	glLoadIdentity();								//Matrix leeren auf 0,0,0
	glPopMatrix();							
	glPushMatrix();
	glTranslatef(0.0f,-2.0f,0.0f);					//um 2 Schritte nach unten verschieben
	glScalef(1.0f,4.0f,1.0f);						//4fache Skalierung in Y-Richtung
	glutSolidCube(1.0);								//Erzeugt den Wuerfel

	//================================= Koerper1 ====================================

	glColor3f (1.0, 1.0, 1.0);//Farbe
	glLoadIdentity();
	glPopMatrix();
	glPushMatrix();
	glRotatef(60.0,0.0f,0.0f,1.0f);					//60 Grad um Z-Achse drehen
	glTranslatef(0.0f,2.0f,0.0f);					//um 2 Schritte nach oben verschieben
	glScalef(1.0f,4.0f,1.0f);						//4fache Skalierung in Y-Richtung
	glutSolidCube(1.0);								//Erzeugt den Wuerfel

	//================================= Koerper2 ====================================

	glColor3f (1.0, 1.0, 1.0);//Farbe
	glLoadIdentity();					//Matrix leeren  auf 0,0,0
	glPopMatrix();
	glPushMatrix();
	glRotatef(120.0,0.0f,1.0f,0.0f);	//120 Grad um Y-Achse drehen
	glRotatef(60.0,0.0f,0.0f,1.0f);		//60 Grad um Z-Achse drehen
	glTranslatef(0.0f,2.0f,0.0f);		//um 2 Schritte nach oben verschieben
	glScalef(1.0f,4.0f,1.0f);			//4fache Skalierung in Y-Richtung
	glutSolidCube(1.0);					//Erzeugt den Wuerfel

	//================================= Koerper3 ====================================

	glColor3f (1.0, 1.0, 1.0);//Farbe
	glLoadIdentity();
	glPopMatrix();
	glRotatef(240.0,0.0f,1.0f,0.0f);	//234 Grad um Y-Achse drehen
	glRotatef(60.0,0.0f,0.0f,1.0f);		//60 Grad um Z-Achse drehen
	glTranslatef(0.0f,2.0f,0.0f);		///um 2 Schritte nach oben verschieben
	glScalef(1.0f,4.0f,1.0f);			//4fache Skalierung in Y-Richtung
	glutSolidCube(1.0);

	//================================================================================
	rotate += 0.01;
	glFlush();
}


